<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>挂号页</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<!-- 引入EasyUI的相关css和js文件 -->
<link href="EasyUI/themes/default/easyui.css" rel="stylesheet"
	type="text/css" />
<link href="EasyUI/themes/icon.css" rel="stylesheet" type="text/css" />
<link href="EasyUI/demo.css" rel="stylesheet" type="text/css" />
<script src="EasyUI/jquery.min.js" type="text/javascript"></script>
<script src="EasyUI/jquery.easyui.min.js" type="text/javascript"></script>
<script src="EasyUI/easyui-lang-zh_CN.js" type="text/javascript"></script>
</head>
<body>
	<script type="text/javascript" charset="UTF-8">
	 function submitRegistration() {
			$("#ff_registration").form("submit", {
				
				url : 'registration/addregistration', 
				success : function(result) {
					var result = eval('(' + result + ')');
					if (result.success == 'true') {
						//显示成功信息
						$.messager.show({
							title : "提示信息",
							msg : result.message,
							 style:{
				                    right:'',
				                    bottom:''
				                }
						});
						//成功后关闭选项卡
					if ($('#tabs').tabs('exists', '挂号管理')) {
								$('#tabs').tabs('close', '挂号管理');
					}	
					} else {
						$.messager.show({
							title : "提示信息",
							msg : result.message
						});
					}
				}
			});
		}	
	
		$(function() {
			$('#dg_doctorinfo').datagrid({
				singleSelect : false, //设置datagrid为单选
				url : 'doctor/querybyform', //为datagrid设置数据源
				//pagination : true, //启用分页
				//pageSize : 10, //设置初始每页记录数（页大小）
				//pageList : [ 10, 15, 20 ], //设置可供选择的页大小
				rownumbers : true, //显示行号
				fit : true, //设置自适应		
				header : '#searchtb_doctorinfo', //为datagrid标头添加搜索栏
				columns : [ [ { //编辑datagrid的列
					title : '序号',
					field : 'no',
					align : 'center',
					checkbox : true
				}, {
					field : 'doctorno',
					title : '医生编号',
					width : 80
				}, {
					field : 'doctorname',
					title : '医生姓名',
					align : 'center',
					width : 80
				}, {
					field : 'department',
					title : '医生科室',

					width : 70
				} ] ]
			});
		});
		function searchDoctor() {	
			var search_doctorname = $('#search_doctorname').textbox("getValue");
			var search_doctorno = $('#search_doctorno').textbox("getValue");
			var search_department = $('#search_department').textbox("getValue");
			var abc = "中文";
			
			$("#dg_doctorinfo").datagrid('load', {
			"doctorno":search_doctorno,
			"doctorname":search_doctorname,
			"department":search_department
			
			});
		}
		
		function loadDoctor() {
			var rows = $("#dg_doctorinfo").datagrid('getSelections');
			if (rows.length > 0) {
				var row = $("#dg_doctorinfo").datagrid("getSelected");
				if (row) {
					$("#dlg_doctordate").dialog("open").dialog('setTitle',
					'选择挂号日期');
					$("#ff_doctordate").form("load", {
						"doctorno" : row.doctorno,																	
					});
					$("#ff_registration").form("load", {
						"department" : row.department,																	
					});
					urls = "registration/newmedicalrecord";
				}
			} else {
				$.messager.alert('提示', '请选择医生', 'info');
			}
		}
		function checkWaitNo() {
			$("#ff_doctordate").form("submit", {
				url : urls, //使用参数				
				success : function(result) {
					var result = eval('(' + result + ')');							
					if (result['registration'].waitno != null) {						
						$("#dlg_doctordate").dialog("close");
						$("#ff_registration").form("load", {
							doctorno :result['registration'].doctorno,
							medicalrecord :result['registration'].medicalrecord,
							waitno :result['registration'].waitno,
							registrationdate : result['registration'].registrationdate,
							//"registrationdate":,
							//"medicalrecord":,
						});
						$.messager.show({
							title : "提示信息",
							msg : "获取等待号成功",
						});	
					
					}					
				}
			});
		}
	</script>

	<div style=""></div>

	<!-- 选择挂号日期对话框 -->
	<div id="dlg_doctordate" class="easyui-dialog" title="选择挂号日期"
		closed="true" style="width: 500px;">
		<div style="padding: 10px 60px 20px 60px">			
			<div style="text-align: center; padding: 5px">
			
			<form id="ff_doctordate" method="POST" action=""
				>
					<tr>
						
						<td><input class="easyui-textbox" type="text" id="doctorno"
							name="doctorno" label="医生编号:" data-options="required:true" readonly="readonly" style="width:100%;"></input></td>
					</tr>
					<br><br><br>
					<tr>											
						<td>   <input class="easyui-datebox" label="挂号日期:" name="registrationdate" id="registrationdate" style="width:100%;">    </td>
					</tr>    
			</form>
				<a href="javascript:void(0)" class="easyui-linkbutton"
					onclick="checkWaitNo();">确定</a> 
			</div>
		</div>
	</div>
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'center',iconCls:'icon-ok'" title="Center">
			<div class="easyui-layout" data-options="fit:true">
				<div data-options="region:'north',split:true" style="height: 50px">
				${sessionScope.patient.name}
				${sessionScope.patient.diagnosticcard}
				${sessionScope.registration.doctorno}
				</div>
				<div data-options="region:'west',split:true" style="width: 320px">

					<table id="dg_doctorinfo" class="easyui-datagrid"></table>
					<!-- 创建查询工具栏 -->
					<div id="searchtb_doctorinfo" style="padding: 2px 5px;">
						<form id="searchForm_doctorinfo" method="post">
							<div style="padding: 3px">
								科室&nbsp;&nbsp;<input class="easyui-textbox" name="department"
									id="search_department" style="width: 110px" />&nbsp;医生编号&nbsp;&nbsp;<input class="easyui-textbox" name="id"
									id="search_doctorno" style="width: 70px" />
							</div>
							<div style="padding: 3px">
								姓名&nbsp;&nbsp;<input class="easyui-textbox" name="name"
									id="search_doctorname" style="width: 110px" /> &nbsp;&nbsp;<a
									href="javascript:void(0)" class="easyui-linkbutton"
									iconCls="icon-search" plain="true" onclick="searchDoctor();">查找</a>
							</div>
						</form>
					</div>
				</div>
				<div data-options="region:'center'">
					       <div style="margin:20px 0;">       
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="loadDoctor()">LoadDoctor</a>       
    </div>
    <div class="easyui-panel" title="挂号表（全部项目必填）" margin:0px auto>
        <form id="ff_registration" method="post">
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" name="patientname" id="patientname" style="width:40%" value="${sessionScope.patient.name}" data-options="label:'姓名:'">
                ------------
                <input class="easyui-textbox" name="diagnosticcard" id="diagnosticcard" value="${sessionScope.patient.diagnosticcard}" style="width:40%" data-options="label:'诊疗卡号:'">
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" name="department" id="department" style="width:40%" data-options="label:'挂号诊室:'">
                ------------
                <input class="easyui-textbox" name="doctorno" value="" id="doctorno" style="width:40%" data-options="label:'医生编号:'">
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" name="waitno" id="waitno" style="width:40%" data-options="label:'等待号:'">
                ------------
                <input class="easyui-textbox" name="medicalrecord" id="medicalrecord" style="width:40%" data-options="label:'处方号:'">
            </div>
            <div style="margin-bottom:20px">
            <input class="easyui-datebox" label="挂号日期:" name="registrationdate" id="registrationdate" style="width:35%;">           
                ------------
                 <select class="easyui-combobox" name="patienttype" id="patienttype" label="病人类型：" style="width:20%"><option value="自费">自费</option><option value="医保卡">医保卡</option></select>
                ------------
              <select class="easyui-combobox" name="registrationtype" id="registrationtype" label="挂号类型：" style="width:20%"><option value="门诊">门诊</option><option value="急诊">急诊</option></select>
            </div>
   
        </form>
        <div style="text-align:center;padding:5px 0">
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitRegistration()" style="width:80px">提交挂号</a>           
        </div>
    </div>
	</div>

</body>
</html>